package br.com.lp3.livraria.util;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.hibernate.loader.custom.Return;

public final class HibernateUtil {

	private static HibernateUtil hibernateUtil;
	private EntityManagerFactory entityManagerFactory;

	private HibernateUtil() {

	}

	public static HibernateUtil getInstancia() {
		if (hibernateUtil == null) {
			hibernateUtil = new HibernateUtil();
		}
		return hibernateUtil;
	}
	
	public EntityManager getEntityManager(){
		 if (entityManagerFactory == null){
			 entityManagerFactory= Persistence.createEntityManagerFactory("persistenceUnit");
		 }
		return entityManagerFactory.createEntityManager();
	}
	
	

}
